package lib.quasar.base.dialog;

import android.app.Activity;
import android.graphics.Color;
import android.os.Bundle;
import android.view.Gravity;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
import android.widget.TextView;

import lib.quasar.util.DimenUtil;
import lib.quasar.widget.line.LineLinearLayout;

public class LoadingDialog extends BaseDialog {

    public LoadingDialog(Activity activity) {
        super(activity);
    }

    @Override
    public void onBackPressed() {
        // super.onBackPressed();
    }

    @Override
    public void show() {
        super.show();
        setCanceledOnTouchOutside(false);
        setCancelable(false);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {

        LinearLayout linearLayout = new LinearLayout(getContext());
        final int width = DimenUtil.dp2px(200);
        final int height = DimenUtil.dp2px(150);
        ViewGroup.LayoutParams params1 = new ViewGroup.LayoutParams(width, height);
        linearLayout.setLayoutParams(params1);
        linearLayout.setOrientation(LineLinearLayout.VERTICAL);

        ProgressBar progressBar = new ProgressBar(getContext());
        final int width2 = DimenUtil.dp2px(50);
        LinearLayout.LayoutParams params2 = new LinearLayout.LayoutParams(width2, width2);
        params2.gravity = Gravity.CENTER_HORIZONTAL;
        params2.topMargin = width2;
        progressBar.setLayoutParams(params2);
        linearLayout.addView(progressBar);

        TextView textView = new TextView(getContext());
        final int height3 = DimenUtil.dp2px(100);
        LinearLayout.LayoutParams params3 = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, height3);
        params3.gravity = Gravity.CENTER;
        textView.setTextColor(Color.BLACK);
        textView.setLayoutParams(params3);
        linearLayout.addView(textView);

        setContentView(linearLayout);
        getWindow().setGravity(Gravity.CENTER);
        getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);

        initData();
    }

    @Override
    protected int initView() {
        return -1;
    }

    @Override
    protected void initData() {
    }
}
